<template>
  <div>
    <el-table
      :data="dataSource"
      style="width: 100%"
    >
      <el-table-column
        prop="date"
        label="订单信息"
      >
        <template slot-scope="data">
          <div style="font-weight: bold;">{{data.row.projectName}}</div>
          <!-- <div>内容002</div> -->
        </template>
      </el-table-column>

      <el-table-column
        prop="orderUserName"
        label="发布人"
      />
      
      <el-table-column
        prop="date"
        label="订单状态"
      >
        <template slot-scope="data">
          <el-tag type="danger" v-if="data.row.status !=undefined">{{data.row.status}}</el-tag>
        </template>
      </el-table-column>

      <el-table-column
        prop="publishTime"
        label="下单时间"
      />

      <el-table-column
        prop="date"
        label="订单详情"
      >
        <template slot-scope="data">
          <el-button type="success" size="small" @click="viewDetailHandle(data.row.id)">查看订单详情</el-button>
        </template>
      </el-table-column>

      <el-table-column
        prop="date"
        label="操作"
        fixed="right"
        width="230"
      >
        <template slot-scope="data">
          <el-button v-if="data.row.status != '发单中'" type="primary" size="small" @click="takePriceHandle(data.row)">修改报价</el-button>
          <el-button v-else type="primary" size="small" @click="takePriceHandle(data.row)">报价</el-button>
          <el-button v-if="data.row.status == '已完成'" @click="onOpenComment(data.row)" type="primary" size="small" >评价</el-button>
          <el-button v-if="data.row.status == '已完成' || data.row.status == '服务中'" @click="onOpenProgress(data.row)" type="primary" size="small" >进度汇报</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="评价"
      :visible.sync="commentVisible"
      width="60%"
      :destroy-on-close="true"
      @close="handleCloseComment">
      <addComment :orderInfo="currentOrder" @onCloseToggle="handleCloseComment"/>
    </el-dialog>
  </div>
</template>

<script>
import addComment from '../want_order/addComment.vue';

export default ({
  name: 'OrderHouseTable',
  components: {
    addComment
  },
  props:['dataSource'],
  data() {
    return {
      commentVisible: false,
      currentOrder: {},
      progressVisible: false
    }
  },
  methods:{
    viewDetailHandle(id) {
      this.$emit("viewDetailHandle",id);
    },
    takePriceHandle(data) {
      console.log('data', data);
      this.$emit("takePriceHandle",data);
    },
    onOpenComment(records) {
      this.currentOrder = { ...records };
      this.commentVisible = true;
    },
    handleCloseComment() {
      this.commentVisible = false;
    },
    onOpenProgress(row) {
      this.$router.push({name:"order_progress", params: { ...row }})
    },
  }
})

</script>
